<?php
class Jifen{
	function chajifen($now_user = ""){
		global $db;
 		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
 		if($db->FetchRow()){
 			return  $db->Get("jifen");
 		}else{
 			return  "查不到積分！";
 		}
	}
	function getnickname($now_user = ""){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
		if($db->FetchRow()){
			return  $db->Get("nickname");
		}else{
			return  "查不到昵稱！";
		}
	}
	function gettool($now_user = ""){
		global $db;
		$phtml =array("display:none","display:none",);
		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
		if($db->FetchRow()){
			switch ($db->Get("root")){
				case 1:
					$phtml = array("display:block", "display:none");
					break;
				case 2:
					$phtml = array("display:block", "display:block");
					break;
				case 3:
					$phtml = array("display:block", "display:block");
					break;
			}
		}
		return  $phtml;
	}
	function updatajifen($now_user = ""){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
		if($db->FetchRow()){
			$nowjifen = $db->Get("jifen")+$this->getyjjf();
			$datep =date("Y-m-d");
			if($db->Get("lastlogin") != $datep){
				$db->ExeSql("update `cu_manage` set jifen='$nowjifen' where username='$now_user'");//寫入登錄時間，以防在同一日內多次獲取積分
			}
		}
	}
	function updatalinshijifen($now_user,$reason){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_manage` WHERE username='$now_user'");
		if($db->FetchRow()){
			$nowjifen = $db->Get("jifen")+$this->getlsjf();
			$db->ExeSql("update `cu_manage` set jifen='$nowjifen' where username='$now_user'");//寫入登錄時間，以防在同一日內多次獲取積分
		}
	}
	function getnotictext(){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_public` WHERE id=1");
	 	if($db->FetchRow()){
 			return  $db->Get("notictext");
 		}else{
 			return  "查不到公告！";
 		}
	}
	function getpublicac(){
		global $db;
		$ac =array("usn" => "查不到","psw" => "查不到",);
		$db->ExeQuerySql("SELECT * FROM `cu_public` WHERE id=1");
		if($db->FetchRow()){
			return  array($db->Get("nbsusername"), $db->Get("nbspassword"));
		}else{
			return  $ac;
		}
	}
	function getyjjf(){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_public` WHERE id=1");
		if($db->FetchRow()){
			return  $db->Get("yjjf");
		}else{
			return  10;
		}
	}
	function getlsjf(){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_public` WHERE id=1");
		if($db->FetchRow()){
			return  $db->Get("lsjf");
		}else{
			return  10;
		}
	}
}